package com.suncreate.zhtz.iot.service.impl;

import com.suncreate.zhtz.iot.model.ScGlobalRunSituation;
import com.suncreate.zhtz.iot.mapper.ScGlobalRunSituationDao;
import com.suncreate.zhtz.iot.service.ScGlobalRunSituationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (ScGlobalRunSituation)表服务实现类
 *
 * @author makejava
 * @since 2021-09-10 16:12:26
 */
@Service("scGlobalRunSituationService")
public class ScGlobalRunSituationServiceImpl implements ScGlobalRunSituationService {
    @Resource
    private ScGlobalRunSituationDao scGlobalRunSituationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param situationKey 主键
     * @return 实例对象
     */
    @Override
    public ScGlobalRunSituation queryById(String situationKey) {
        return this.scGlobalRunSituationDao.queryById(situationKey);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<ScGlobalRunSituation> queryAllByLimit(int offset, int limit) {
        return this.scGlobalRunSituationDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param scGlobalRunSituation 实例对象
     * @return 实例对象
     */
    @Override
    public ScGlobalRunSituation insert(ScGlobalRunSituation scGlobalRunSituation) {
        this.scGlobalRunSituationDao.insert(scGlobalRunSituation);
        return scGlobalRunSituation;
    }

    /**
     * 修改数据
     *
     * @param scGlobalRunSituation 实例对象
     * @return 实例对象
     */
    @Override
    public ScGlobalRunSituation update(ScGlobalRunSituation scGlobalRunSituation) {
        this.scGlobalRunSituationDao.update(scGlobalRunSituation);
        return this.queryById(scGlobalRunSituation.getSituationKey());
    }

    /**
     * 通过主键删除数据
     *
     * @param situationKey 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String situationKey) {
        return this.scGlobalRunSituationDao.deleteById(situationKey) > 0;
    }
}
